define([],function(){
    var tpl = {};

    tpl.info = function(){
        return info();
    }
    tpl.title = function(){
		return title();
	}
	tpl.table = function() {
        return table();
    }
    tpl.add = function() {
        return add();
    }
    tpl.smallClass = function() {
        return smallClass();
    }
    tpl.selectCallBack = function() {
        return selectCallBack();
    }

    /* 基本信息 */
    var info = function(){
        return  '<script id="tpl_treatPlanCourseEdit_info" type="text/html">' +
                '    <span>门诊号：{{hisNo}}</span>'+
                '    <span>姓名：{{userName}}</span>'+
                '    <span>{{schemeName}}</span>'+
                '    <span>分组：{{if groupValue=="00"}}不随机{{else if groupValue=="01"}}随机A{{else if groupValue=="02"}}随机B{{else if groupValue=="03"}}随机D{{else if groupValue=="04"}}随机I{{/if}}</span>'+
                '</script>';
    }
    var title = function(){
		return 	'<script id="tpl_treatPlanCourseEdit_title" type="text/html">'+
				'	<span>{{stageName}}</span>'+
				'	<i>></i>'+
				'	<span>{{courseName}}</span>'+
				'</script>';
	}
	var table = function(){
		return  '<script id="tpl_treatPlanCourseEdit_table" type="text/html">' +
				'	<thead>'+
				'   	<tr>' +
    	        '   	    <th>天数</th>' +
    	        '   	    <th>日期</th>' +
                '   	    {{if medicines.length>0}}' +
                '   	        {{each medicines as value i}}' +
                '   	            <th data-seqNo="{{value.seqNo}}" data-medicineId="{{value.medicineId}}">'+
                '   	                {{if flag && i!=0}}<div class="course-list-upBtn setCourseSort"><-</div>{{/if}}'+
                '   	                <div class="course-list-medicineName" data-medSkuId="{{value.medSkuId}}">'+
                '   	                    <span>{{value.medicineName}}</span><br>'+
                '   	                    {{value.medicineDose}}{{value.medUnitName}}'+
                '   	                </div>'+
                '   	                {{if flag && i!=medicines.length-1}}<div class="course-list-downBtn setCourseSort">-></div>{{/if}}'+
                '   	                {{if flag}}<div class="delBtn" nums="{{value.frequencyTime}}"><i class="fa fa-minus-circle"></i></div>{{/if}}'+
                '   	            </th>' +
                '   	        {{/each}}' +
                '   	    {{/if}}' +
                '   	    {{if flag}}<th class="add-medicine"><span>新增药物</span><br><i class="fa fa-plus-circle"></i></th>{{/if}}' +
                '   	</tr>' +
				'	</thead>'+
				'	<tbody>'+
				'   	{{if days.length==0}}' +
                '       	<tr><td colspan="100%">暂无数据</td></tr>' +
                '   	{{else}}' +
                '       	{{each days as value}}' +
                '           	<tr data-index="{{value.seqDay}}">' +
                '               	<td>{{value.seqDay}}{{if flag}}<i class="delDay fa fa-minus"></i>{{/if}}</td>' +
                '               	<td>{{value.dealDate}}</td>' +
                '               	{{each value.medicines as val}}' +
                '                   	<td class="medicine-dose" data-medicineId="{{val.medicineId}}">{{val.deValue}}</td>' +
                '               	{{/each}}' +
                '               	{{if flag}}<td></td>{{/if}}' +
                '           	</tr>' +
                '       	{{/each}}' +
                '   	{{/if}}' +
                '   	{{if flag}}<tr id="increaseDay" class="increase-day"><td colspan="100%"><i class="fa fa-plus"></i></td></tr>{{/if}}' +
				'	</tbody>'+
				'</script>';
	}
	var add = function() {
        return  '<script id="tpl_treatPlanCourseEdit_add" type="text/html">' +
                '   <div class="courseEdit-modal">'+
                '       <div class="form-horizontal clearfix">'+
                '          <div class="form-group col-sm-12 col-md-12">'+
                '              <label class="control-label"><i class="no-null">*</i>药品名称</label>'+
                '              <div class="control-input position-relative">'+
                '                  <input type="text" class="form-control" id="medicineName" placeholder="请输入药品名称" value="{{medicine_name}}" {{if status=="readonly" || status=="update"}}readonly{{/if}}>'+
                '                  <div id="inputQuery" class="medicine-list"></div>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-6 col-md-6">'+
                '              <label class="control-label"><i class="no-null">*</i>药品大类</label>'+
                '              <div class="control-input">'+
                '                  <select class="form-control" id="classId" {{if status=="readonly" || status=="update"}}disabled{{/if}}>' +
                '                      {{each bigClass as value i}}' +
                '                          <option value="{{value.id}}" {{if value.id==class_id}}selected{{/if}}>{{value.className}}</option>' +
                '                      {{/each}}' +
                '                  </select>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-6 col-md-6 grid-label-7">'+
                '              <label class="control-label"><i class="no-null">*</i>药品小类</label>'+
                '              <div class="control-input">'+
                '                  <select class="form-control" id="catalogId" {{if status=="readonly" || status=="update"}}disabled{{/if}}>' +
                '                      {{each smallClass as value i}}' +
                '                          <option value="{{value.id}}" {{if value.id==parentId}}selected{{/if}}>{{value.catalog_name}}</option>' +
                '                      {{/each}}' +
                '                  </select>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-6 col-md-6">'+
                '              <label class="control-label"><i class="no-null">*</i>服用周期</label>'+
                '              <div class="control-input frequency clearfix">'+
                '                  <input id="frequencyDay" type="number" min="0" value="{{frequency_day}}" placeholder="天"  class="form-control" {{if status=="readonly"}}readonly{{/if}}><span>天</span>' +
                '                  <input id="frequencyTime" type="number" min="0" value="{{frequency_time}}" placeholder="次"  class="form-control" {{if status=="readonly"}}readonly{{/if}}><span>次</span>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-6 col-md-6 grid-label-7">'+
                '              <label class="control-label"><i class="no-null">*</i>计算方式</label>'+
                '              <div class="control-input">'+
                '                  <select class="form-control" id="calcuMethod" {{if status=="readonly"}}disabled{{/if}}>' +
                '                      <option value="01" {{if calcu_method=="01"}}selected{{/if}}>体表面积</option>' +
                '                      <option value="02" {{if calcu_method=="02"}}selected{{/if}}>体重</option>' +
                '                  </select>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-6 col-md-6">'+
                '              <label class="control-label"><i class="no-null">*</i>药品剂量</label>'+
                '              <div class="control-input">'+
                '                  <input type="text" class="form-control" id="medicineDose" placeholder="请输入药品总剂量" value="{{medicine_dose}}" {{if status=="readonly"}}readonly{{/if}}>'+
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-6 col-md-6 grid-label-7">'+
                '              <label class="control-label"><i class="no-null">*</i>药品剂量单位</label>'+
                '              <div class="control-input">'+
                '                  <select class="form-control" id="medUnitId" {{if status=="readonly" || status=="update"}}disabled{{/if}}>' +
                '                      {{each units as value i}}' +
                '                          <option value="{{value.id}}" {{if med_unit_id==value.id}}selected{{/if}}>{{value.unit_name}}</option>' +
                '                      {{/each}}' +
                '                  </select>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-6 col-md-6">'+
                '              <label class="control-label"><i class="no-null">*</i>药品类型</label>'+
                '              <div class="control-input">'+
                '                  <select class="form-control" id="medicineType" disabled>' +
                '                      <option value="1" {{if medicine_type=="1"}}selected{{/if}}>正常用药</option>' +
                '                      <option value="2" {{if medicine_type=="2"}}selected{{/if}}>补充用药</option>' +
                '                  </select>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-6 col-md-6 grid-label-7">'+
                '              <label class="control-label">药品性状</label>'+
                '              <div class="control-input">'+
                '                  <input type="text" class="form-control" id="character" value="{{character}}" {{if status=="readonly" || status=="update"}}readonly{{/if}}>'+
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-12 col-md-12">'+
                '              <label class="control-label">适用症</label>'+
                '              <div class="control-input">'+
                '                  <input type="text" class="form-control" id="indication" value="{{indication}}" {{if status=="readonly" || status=="update"}}readonly{{/if}}>'+
                '              </div>'+
                '          </div>'+
                 '          <div class="form-group col-sm-12 col-md-12">'+
                '              <label class="control-label">不良反应</label>'+
                '              <div class="control-input">'+
                '                  <textarea id="adverseReaction" class="form-control" {{if status=="readonly" || status=="update"}}readonly{{/if}}>{{adverse_reaction}}</textarea>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-12 col-md-12">'+
                '              <label class="control-label">禁忌</label>'+
                '              <div class="control-input">'+
                '                  <textarea id="taboo" class="form-control" {{if status=="readonly" || status=="update"}}readonly{{/if}}>{{taboo}}</textarea>' +
                '              </div>'+
                '          </div>'+
                '          <div class="form-group col-sm-12 col-md-12">'+
                '              <label class="control-label">注意事项</label>'+
                '              <div class="control-input">'+
                '                  <textarea id="considerations" class="form-control" {{if status=="readonly" || status=="update"}}readonly{{/if}}>{{considerations}}</textarea>' +
                '              </div>'+
                '          </div>'+
                '       </div>'+
                '       <div class="btn-box">'+
                '           <div class="resetBtn" id="reset">重置</div>' +
                '           <div class="editMedicBtn" id="add" data-id="{{id}}" data-medicineId="{{medicine_id}}">添加</div>' +
                '       </div>'+
                '   </div>'+
                '</script>';
    }
    var smallClass = function() {
        return  '<script id="tpl_treatPlanCourseEdit_smallClass" type="text/html">' +
                '   {{each list as value i}}' +
                '       <option value="{{value.id}}">{{value.catalog_name}}</option>' +
                '   {{/each}}' +
                '</script>';
    }
    var selectCallBack = function() {
        return  '<script id="tpl_treatPlanCourseEdit_select" type="text/html">' +
                '   {{each list as value i}}' +
                '	  <p class="query_item" id="{{value.id}}">{{value.medicine_name}} {{value.medicine_dose}}{{value.med_unit_name}} {{value.frequency_day}}天{{value.frequency_time}}次 {{if value.calcu_method=="01"}}体表面积{{else if value.calcu_method=="02"}}体重{{/if}} {{if value.medicine_type=="1"}}正常用药{{else if value.medicine_type=="2"}}补充用药{{/if}} {{value.parentCatalogName}}</p>' +
                '   {{/each}}' +
                '</script>';
    }

    return tpl;
});